package cn.yili12.business.mq;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;


@Component
@Slf4j
public class QueueProducer {
    @Resource
    private JmsTemplate jmsTemplate;

    /**
     * 用于发送消息到mq服务
     *
     * @param destination queue或者topic
     * @param message     消息体
     */
    public void send(String destination, String message) {
        this.jmsTemplate.convertAndSend(destination, message);
        log.info("发送消息成功，发送方式：{}，发送内容：{}", destination, message);
    }
}